Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unify BPF verifiers #177

Merged
merged 1 commit into from
May 28, 2021
Merged

Conversation

jackcmay
Copy link
Collaborator

There are currently two bpf verifiers, one in the rbpf crate and one in the bpf_loader crate in the Solana repo. Only the one in the bpf_loader crate is used by the cluster but having two is confusing.

This PR pulls the verifier from the bpf_loader crate and makes the necessary changes in prep for the bpf_loader crate to switch over to the updated one in the rbpf create.

@jackcmay jackcmay force-pushed the consolidate-bpf-verifier branch 2 times, most recently from 5e3efaf to 5b97b3f Compare May 26, 2021 02:18
Copy link

@Lichtso Lichtso left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets talk about these changes first, some changes in the RBPF repo might be useful and should make it to the mono repo. Or even better, let the mono repo just use this verifier with only the absolutely necessary changes applied.

src/verifier.rs Outdated Show resolved Hide resolved
src/verifier.rs Show resolved Hide resolved
src/verifier.rs Show resolved Hide resolved
src/verifier.rs Show resolved Hide resolved
@@ -258,7 +253,7 @@ pub fn check(prog: &[u8]) -> Result<(), UserError> {
ebpf::ADD64_REG => {},
ebpf::SUB64_IMM => {},
ebpf::SUB64_REG => {},
ebpf::MUL64_IMM => {},
ebpf::MUL64_IMM => { check_imm_nonzero(&insn, insn_ptr)?; },
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Semantic difference

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, stale in rbpf

Copy link

@Lichtso Lichtso May 26, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, this was removed here but not in the mono repo I think.
And I would carry the removal forward as MUL32_IMM also has no such limit.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, I'll take a look if we can remove it from the monorepo

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should remove from the monorepo in s separate PR, probably with featurization, tracking here: solana-labs/solana#17520

tests/ubpf_execution.rs Show resolved Hide resolved
tests/ubpf_verifier.rs Show resolved Hide resolved
@jackcmay jackcmay force-pushed the consolidate-bpf-verifier branch from 5b97b3f to 014ce37 Compare May 26, 2021 23:30
tests/ubpf_execution.rs Outdated Show resolved Hide resolved
@jackcmay jackcmay requested a review from Lichtso May 26, 2021 23:32
@jackcmay jackcmay force-pushed the consolidate-bpf-verifier branch from 014ce37 to 38927bd Compare May 27, 2021 17:33
Copy link

@Lichtso Lichtso left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about the changes related to clippy::upper_case_acronyms?
And this added space here:

if !check_closure(&vm, result) || !solana_rbpf::vm::Tracer::compare(&_tracer_interpreter, tracer_jit) {

Otherwise I think it is ready to go.

tests/ubpf_execution.rs Outdated Show resolved Hide resolved
tests/ubpf_execution.rs Outdated Show resolved Hide resolved
@@ -61,7 +59,7 @@ macro_rules! test_interpreter_and_jit {
$(test_interpreter_and_jit!(bind, vm, $location => $syscall_function; $syscall_context_object);)*
let result = vm.execute_program_jit(&mut TestInstructionMeter { remaining: $expected_instruction_count });
let tracer_jit = vm.get_tracer();
if !check_closure(&vm, result) || !solana_rbpf::vm::Tracer::compare(&_tracer_interpreter, tracer_jit) {
if !check_closure(&vm, result) || !solana_rbpf::vm::Tracer::compare(&_tracer_interpreter, tracer_jit) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Debugging hiccup?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cargo fmt sucks in macros

@jackcmay
Copy link
Collaborator Author

What about the changes related to clippy::upper_case_acronyms?
And this added space here:

if !check_closure(&vm, result) || !solana_rbpf::vm::Tracer::compare(&_tracer_interpreter, tracer_jit) {

Otherwise I think it is ready to go.

I like the upper case for things like instruction names "LDDW" rather than "Lddw" and think this is a good place to make that exception. But, I could go either way if you feel stronger about it

@Lichtso
Copy link

Lichtso commented May 28, 2021

I liked them as well, but in other places we also go with the clippy flow.
So for the purpose of consistency I would not revert these changes (do as clippy says).

@jackcmay jackcmay force-pushed the consolidate-bpf-verifier branch from 38927bd to 79f5375 Compare May 28, 2021 07:57
@jackcmay
Copy link
Collaborator Author

I liked them as well, but in other places we also go with the clippy flow.
So for the purpose of consistency I would not revert these changes (do as clippy says).

Apparently clippy no longer cares...

@jackcmay jackcmay merged commit d644b1a into solana-labs:main May 28, 2021
@jackcmay jackcmay deleted the consolidate-bpf-verifier branch May 28, 2021 15:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants